package c1705;

import java.util.Scanner;

public class E {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        while (cin.hasNext()) {
            String str = cin.next();
            char[] arry = str.toCharArray();
            int max = 0, cnt = 0;
            for (char e : arry) {
                if (e == '(') {
                    ++cnt;
                } else {
                    --cnt;
                }
                max = Math.max(max, cnt);
            }
            System.out.println(max);
        }
        cin.close();
    }
}
